package de.baumann.browser.present

import de.baumann.browser.api.OdinObserver
import de.baumann.browser.api.net.vo.Order
import de.baumann.browser.base.BasePresenter
import de.baumann.browser.iview.IRechargeOrderDetailView
import de.baumann.browser.model.OrderModel

class RechargeOrderDetaiPresenter :BasePresenter<IRechargeOrderDetailView>(){
    fun getRechargeDetail() {
        OrderModel().getRechargeDetail(view.getOrderId())
                .subscribe(object :OdinObserver<Order>(){
                    override fun onSuccess(data: Order?) {
                        if (view==null || data == null){
                            return
                        }
                        view.setRechargeAmount(data.orderAmount)
                        view.setRechargeId(data.orderId)
                        view.setTransactionId(data.txHash)
                        view.setArrivald(data.toAddr)
                        view.setTime(data.orderTime)
                        if (data.orderStatus == 1) {
                            view.actualArrival(data.orderAmount)
                        } else {
                            view.actualArrival("0.0000")
                        }
                        view.handlingFee("0")
                        view.setRechargeStatus(data.orderStatus, data.remark)
                    }
                })
    }
}